package com.ti.demo.configuration;

import com.ti.demo.service.WeatherService;
import org.springframework.ai.tool.ToolCallbackProvider;
import org.springframework.ai.tool.method.MethodToolCallbackProvider;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestClient;

/**
 * @description: com.ti.demo.configuration
 * @Author Triagen
 * @Date 2025/10/10 17:04
 */
@Configuration
public class ToolConfiguration {
    @Bean
    public RestClient getRestClient(ObjectProvider<RestClient.Builder> restClientBuilderProvider) {
        return restClientBuilderProvider.getIfAvailable(RestClient::builder).baseUrl("https://weather.cma.cn/api").build();
    }

    @Bean
    public ToolCallbackProvider weatherTools(WeatherService weatherService) {
        return MethodToolCallbackProvider.builder()
                .toolObjects(weatherService)
                .build();
    }
}
